function setFieldOrder(id,type) {
    if (nowDetailMode!=null&&nowDetailMode!="") {
        alert('请在非过滤模式下进行排序')
    } else {
        //var temp = Ext.getCmp('attrPanelFieldsetForm'+col)
        //var length = temp.items.items.length
        //console.log(Ext.getCmp('configField'+id))
        for (var i=0;i<3;i++) {
                var index = Ext.getCmp('attrPanelFieldsetForm'+i).items.indexOf(Ext.getCmp('configField'+id))
                if (index!=-1) {
                    if (type==1) {
                        var temp = i-1
                        if (temp==-1) {
                            temp=2
                        }
                        var objectFrom = Ext.clone(Ext.getCmp('configField'+id))
                        var objectTo = Ext.clone(Ext.getCmp('attrPanelFieldsetForm'+temp).getComponent(index))
                        //Ext.getCmp('attrPanelFieldsetForm'+i).items.indexOf()
                        Ext.getCmp('attrPanelFieldsetForm'+temp).moveBefore(objectFrom,Ext.getCmp('attrPanelFieldsetForm'+temp).getComponent(index))
                        Ext.getCmp('attrPanelFieldsetForm'+i).moveBefore(Ext.getCmp('attrPanelFieldsetForm'+temp).getComponent(index+1),
                        Ext.getCmp('attrPanelFieldsetForm'+i).getComponent(index))
                    }
                    if (type==2) {
                        Ext.getCmp('attrPanelFieldsetForm'+i).moveBefore(Ext.getCmp('configField'+id),Ext.getCmp('attrPanelFieldsetForm'+i).getComponent(index-1))
                        
                    }
                    if (type==3) {
                        var temp = i+1
                        if (temp==3) {
                            temp=0
                        }
                        var objectFrom = Ext.clone(Ext.getCmp('configField'+id))
                        var objectTo = Ext.clone(Ext.getCmp('attrPanelFieldsetForm'+temp).getComponent(index))
                        Ext.getCmp('attrPanelFieldsetForm'+temp).moveBefore(objectFrom,Ext.getCmp('attrPanelFieldsetForm'+temp).getComponent(index))
                        Ext.getCmp('attrPanelFieldsetForm'+i).moveBefore(Ext.getCmp('attrPanelFieldsetForm'+temp).getComponent(index+1),
                        Ext.getCmp('attrPanelFieldsetForm'+i).getComponent(index))
                    }
                    if (type==4) {
                        Ext.getCmp('attrPanelFieldsetForm'+i).moveAfter(Ext.getCmp('configField'+id),Ext.getCmp('attrPanelFieldsetForm'+i).getComponent(index+1))
                    }
                    break
                }
        }     
        
        var ids = []
        var indexs = []
        var flag = 0
        for (var i=0;i<3;i++) {
            var length = Ext.getCmp('attrPanelFieldsetForm'+i).items.items.length
            for (var j=0;j<length;j++) {
                var id = Ext.getCmp('attrPanelFieldsetForm'+i).items.items[j].id.substring(11)
                ids.push(id)
                flag = j*3+i
                indexs.push(flag)
                //flag ++
                console.log(id)
            }
        }

        Ext.Ajax.request({
            url: "../dev/saveoptionindex",
            params: {ids:ids.join(","),indexs:indexs.join(",")},
            success:function(response, opts) {
                                               
            }
        }); 
        
    }
}


function chartBandUp() {
    var index = Ext.getCmp('chartTree').getSelection()[0].data.index
    var id = Ext.getCmp('chartTree').getSelection()[0].data.id.substring(8)
    var nodes = Ext.getCmp('chartTree').getSelection()[0].parentNode.childNodes
    console.log(Ext.getCmp('chartTree').getSelection()[0].data.id.substring(8))
    for (var i=(index-1);i>=0;i--) {
        if (nodes[i].data.visible) {
            Ext.getCmp('chartTree').getSelection()[0].parentNode.insertChild(i,Ext.getCmp('chartTree').getSelection()[0])
            break
        }
    }
    saveCategorySeq()
    //Ext.getCmp("chartTree").getSelectionModel().select(Ext.getCmp('chartTree').getSelection()[0])
}

function chartBandDown() {
    var index = Ext.getCmp('chartTree').getSelection()[0].data.index
    var id = Ext.getCmp('chartTree').getSelection()[0].data.id.substring(8)
    var nodes = Ext.getCmp('chartTree').getSelection()[0].parentNode.childNodes
    for (var i=(index+1);i<nodes.length;i++) {
        if (nodes[i].data.visible) {
            Ext.getCmp('chartTree').getSelection()[0].parentNode.insertChild(i+1,Ext.getCmp('chartTree').getSelection()[0])
            break
        }
    }

    saveCategorySeq()
}


function saveCategorySeq() {
    var childNodes = Ext.getCmp('chartTree').getSelection()[0].parentNode.childNodes
    var indexs = []
    var ids = []
    for(var i=0;i<childNodes.length;i++) {
        ids.push(childNodes[i].id.substring(8))
        console.log(childNodes[i].data.text)
        indexs.push(childNodes[i].data.index)
    }
    console.log(indexs.join(","))
    console.log(ids.join(","))
    Ext.Ajax.request({
        url: "../dev/savecategoryindex",
        params: {ids:ids,indexs:indexs},
        success:function(response, opts) {
                                              
        }
    }); 
}

function setOptionDetailFlag(id) {
    Ext.Ajax.request({
        url: "../app/setdetailmode",
        params: {id:id,detailMode:nowDetailMode},
        success:function(response, opts) {
            if (nowDetailMode!=null&&nowDetailMode!="") {
                Ext.getCmp('configField'+id).setHidden(true)
            }
        }
    }); 
}

function setOptionOrder(id) {
    Ext.Ajax.request({
        url: "../dev/setoptionorder",
        params: {id:id,seq:$('#optionOrder'+id).val()},
        success:function(response, opts) {
            
        }
    }); 
}


function setOptionGroup(groupId,optionCategoryId) {
    var groupName = $('#attrPanelFieldsetInput'+groupId).val()
    if (groupName!=null && groupName!="") {
        var title = groupName+'<span class="dev" style="" ><input style="width:80px"  id="attrPanelFieldsetInput'+groupId+'"/><a href=javascript:setOptionGroup('+groupId+',"'+optionCategoryId+'") style="color:blue">✓</a></span>'
        Ext.getCmp('attrPanelFieldset'+groupId).setTitle(title)                
        Ext.Ajax.request({
            url: "../dev/setoptiongroup",
            params: {groupId:groupId,groupName:groupName,optionCategoryId:optionCategoryId},
            success:function(response, opts) {
                
            }
        }); 
    }


    /*var fieldSetItems = Ext.getCmp('attrPanelFieldset'+groupId).items.items
    for(var i=0;i<fieldSetItems.length;i++) {
        for(var j=0;j<fieldSetItems[i].items.items.length;j++) {
            if (fieldSetItems[i].items.items[j].id!=null) {

            }
        }
    }*/
    for(var i=0;i<$('.orderClass').length;i++) {
        $('.orderClass')[i].click()
    }


}